﻿using IterationLife.FootballTeaching.Models;
using Util.Datas.Ef;

namespace IterationLife.Datas.Mappings.FootballTeachings {
    /// <summary>
    /// 章节映射配置
    /// </summary>
    public class ChapterMap : AggregateRootMapBase<Chapter> {
        /// <summary>
        /// 映射表
        /// </summary>
        protected override void MapTable() {
            ToTable( "Chapters", "FootballTeaching" );
        }
        
        /// <summary>
        /// 映射属性
        /// </summary>
        protected override void MapProperties() {
            //章节编号
            Property(t => t.Id)
                .HasColumnName("ChapterId");
        }
        
        /// <summary>
        /// 映射导航属性
        /// </summary>
        protected override void MapAssociations() {
            //课程
            HasRequired(t => t.Course)
                .WithMany(t => t.Chapters)
                .HasForeignKey(d => d.CourseId);
        }
    }
}